Skip to content

[Php81] Keep nullable param on NewInInitializerRector#7545

Merged
TomasVotruba merged 1 commit into
mainfrom
keep-nullable
Oct 23, 2025
Merged

[Php81] Keep nullable param on NewInInitializerRector#7545
TomasVotruba merged 1 commit into
mainfrom
keep-nullable

Conversation

@samsonasik
Copy link
Copy Markdown
Member

@samsonasik samsonasik commented Oct 22, 2025

@TomasVotruba per our discussion on 153fc78#r168615132

since the rule register back to php81 set, this safe belt keep nullable is needed.

this to avoid new issue opened again:

This needs to be nullable, or it will not safe, however, the drawback is property itself become nullable, while it originally not, as it always initialized inside constructor before.

This also ensure no bc break

@samsonasik
Copy link
Copy Markdown
Member Author

Ready to merge 👍

@TomasVotruba
Copy link
Copy Markdown
Member

Thank you. I'm wondering how this rule could be ever useful. I personally never saw it practice, except nested PHP attributes :)

Let's give this another round and collect feedback in real projects. The nullable property might be good enough to use the feature in codebase 👍

@TomasVotruba TomasVotruba merged commit b4e964f into main Oct 23, 2025
52 checks passed
@TomasVotruba TomasVotruba deleted the keep-nullable branch October 23, 2025 07:29
@samsonasik
Copy link
Copy Markdown
Member Author

samsonasik commented Oct 23, 2025

@TomasVotruba you can see example on spiral framework that it cause bc break

https://github.com/spiral/framework/blob/3d1055a956093bc7a72e531cf55fb5c3e410ab29/rector.php#L96

so skip there, make nullable is the way it has less bc break.

@TomasVotruba
Copy link
Copy Markdown
Member

We need exact code structure.

@samsonasik
Copy link
Copy Markdown
Member Author

samsonasik commented Oct 23, 2025

@TomasVotruba see exact example commit

spiral/framework@9cf5a48

that reverted previous apply and skip the new in initializers, because nullable removed

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 5, 2026

This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants